from aiogram_dialog import DialogManager
from fluentogram import TranslatorRunner

from poker_bot.database.services import AccountService, UserService


async def unconfirmed_accounts_getter(
    dialog_manager: DialogManager, account_service: AccountService, **kwargs
):
    unconfirmed_accounts = await account_service.get_accounts_for_confirmation()

    return {"unconfirmed_accounts": unconfirmed_accounts}


async def account_info_getter(
    dialog_manager: DialogManager,
    locale: TranslatorRunner,
    account_service: AccountService,
    user_service: UserService,
    **kwargs
):
    account_id = dialog_manager.dialog_data.get("account_id")

    account = await account_service.get_account_by_id(account_id)
    user = await user_service.get_user_by_id(account.user_id)

    return {
        "account_id": account.account_id,
        "status": account.status,
        "status_value": locale.get(account.status.value),
        "username": user.username,
        "was_created": account.created_at,
    }
